package com.test.webflux.config.router;

import com.test.webflux.entity.Product;
import com.test.webflux.entity.ResponseResult;
import com.test.webflux.service.ProductService;
import com.test.webflux.service.UserService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * TODO
 *
 * @Description
 * @Author lingmin
 * @Date 2025/4/14 16:29
 **/
public class UserRouter {


    /**
     * 用户路由
     * @param userService
     * @return
     */
    public RouterFunction<ServerResponse> userRoutes(UserService userService) {
        return RouterFunctions.route()
                .path("/user", builder -> builder  // 所有 /user 下的路由
                        .GET("/title", request -> ServerResponse.ok().body(userService.getTitle() , String.class))
                        .GET("/list", request -> ServerResponse.ok().body(userService.list() , ResponseResult.class))
                )
                .build();
    }
}
